﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace one4all_UI
{
    class TweetTextBox:System.Windows.Forms.TextBox
    {
        public string defaultText = "Enter your Tweet...";
        public event EventHandler submit;
        
        public TweetTextBox()
        {
            this.Text = defaultText;
            this.AcceptsReturn = false;
            this.Multiline = true;
            this.Text = defaultText;
            this.WordWrap = true;
            this.ForeColor = Color.Gray;
            this.Font = new Font(this.Font, FontStyle.Italic);
            this.Click += delegate
            {
                if (this.Text != this.defaultText)
                {
                    this.SelectAll();
                }
                else
                {
                    this.TextEnterMode();
                }

            };
        }



        public void StandbyMode()
        {
            this.ForeColor = Color.Gray;
            this.Font = new Font(this.Font, FontStyle.Italic);
            this.Text = defaultText;
        }

        public void TextEnterMode()
        {
            this.Text = "";
            this.Font = new Font(this.Font, FontStyle.Regular);
            this.ForeColor = Color.Black;
        }

        protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg, System.Windows.Forms.Keys keyData)
        {
            if (keyData == System.Windows.Forms.Keys.Enter)
            {
                submit(this, EventArgs.Empty);
                StandbyMode();
                return true;
            }
            return base.ProcessCmdKey(ref msg, keyData);
        }

    }
}
